package com.vains.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.vains.entity.OauthPermission;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 资源表 Mapper 接口
 * </p>
 *
 * @author vains
 * @since 2021-03-17
 */
public interface OauthPermissionMapper extends BaseMapper<OauthPermission> {

    /**
     * 查询权限url
     * @param userId 用户ID
     * @return 返回权限url
     */
    @Select("SELECT op.permission_url FROM oauth_user ou, oauth_role ro, oauth_permission op, oauth_user_role our, oauth_role_permission orp WHERE ou.user_id = our.user_id AND ro.role_id = our.role_id AND op.permission_id = orp.permission_id AND ro.role_id = orp.role_id and op.permission_deleted = 0 and ou.user_id = #{userId }")
    List<String> selectPermissionsByUserId(@Param("userId") Long userId);
}
